#include "Reader.h"
#include <fstream>
#include <iostream>
#include "Imp/ReaderImp.h"

using namespace std;

namespace KVConfig
{
    Reader::Reader()
        : m_pImp(new ReaderImp)
    {
    }

    Reader::~Reader()
    {
        if (m_pImp != NULL) {
            delete m_pImp;
            m_pImp = NULL;
        }
    }

    void Reader::setKVSparator(char cKVSp)
    {
        m_pImp->setKVSparator(cKVSp);
    }

    void Reader::setCommentSparator(char cCommentSp)
    {
        m_pImp->setCommentSparator(cCommentSp);
    }

    bool Reader::parseString(const std::string &context, Data &data) const
    {
        return m_pImp->parseString(context, data);
    }

    bool Reader::parseFile(const std::string &file_name, Data &data) const
    {
        return m_pImp->parseFile(file_name, data);
    }

    /**
     * ====== Test ======
     */

    int Reader::selfTest()
    {
        return ReaderImp::selfTest();
    }
}
